Laravel Convert Word file images to PDF - pdf

I am tring to convert my word file into pdf
laravel/dompdf
and
phpoffice/phpword
to convert word file into pdf and that is woking fine but it removes all the spaces from the text if word file is not containing any image but in case if word file is containing any media/image it disturb the whole pdf layout and structure this is my code from the controller
\PhpOffice\PhpWord\Settings::setPdfRendererPath($request->file);
\PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');
//Load word file
$Content = \PhpOffice\PhpWord\IOFactory::load($request->file);
//Save it into PDF
$PDFWriter = \PhpOffice\PhpWord\IOFactory::createWriter($Content, 'PDF');
$PDFWriter->save(public_path('uploads/word-to-pdf/'. pathinfo($request->file->getClientOriginalName(), PATHINFO_FILENAME).'.pdf'));
please guide me for this what is the solution for this thanks in advance

Related

Why the ordinate of SetFixedPosition() in Itext7 .NET not work well in Web Application?

I used itext7 .NET to make a demo of Console project to add text into an existing pdf. the code is below:
PdfDocument pdfTemple = new PdfDocument(new PdfReader(templateFile), new PdfWriter(templeFile));
Document documentTemple = new Document(pdfTemple, PageSize.A4);
Text text = new Text(string.Format(#"{0} / {1} ", month, year))
.SetBackgroundColor(ColorConstants.WHITE)
.SetBold()
.SetFontSize(11);
documentTemple.Add(new Paragraph(text).SetFixedPosition(1, 424, 740, 60));
text = new Text(DateTime.Now.ToString("MM/dd/yyy"))
.SetBackgroundColor(ColorConstants.WHITE)
//.SetBold()
.SetFontSize(10);
documentTemple.Add(new Paragraph(text).SetFixedPosition(1, 503, 710, 60));
documentTemple.Close();
It works well in the Console project demo. But when I use the same code in a web application (MVC, .NET4.7.2), it doesn't work. Only the text with the ordinate between 50 - 350 can display on the created pdf file.
I need to add text to the position on the pdf file with the ordinate between 40 and 740. How can I let it work in my web application (MVC, .NET4.7.2)?
Thanks.
additions:
I found that if I open the template pdf (I write text into it) with photoshop, I will get such screen:
If I write text into the white area shown in the screenshot above, the text will not show on the pdf file. but if I write text into another area, the text will show on the pdf file.

How to import French characters from .txt file into a PDF form?

We export information out of our CRM (via a tab delimited text file) and import the data into a PDF form. This process used to work but recently any French characters in the text file do not import into the PDF——it turns into a jumbled mess of characters.
Adobe has said it could be a bug but there's been no resolution yet.
I'm thinking it might be an issue of setting the files with the correct format/unicode. I can supply example files.
Step 1: we export the information as a .csv file (French characters intact)
Step 2: Save the .csv file as Tab Delimited Text (.txt) (French characters intact)
Step 3: In the PDF, import data selecting the .txt file. (French characters get jumbled)

Change font size in text box - apache poi word docx

I found the answer that explains how to insert a new text box into docx document.
create text box in document .docx using apache poi
The problem is that I cannot change the font size inside a newly created text box.
Does anyone know how to do that?
Reference : create text box in document .docx using apache poi
The ctTxbxContent.addNewP() in my code creates a CTP object. The XWPFParagraph has a constructor XWPFParagraph(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP prgrph, IBody part). So you can get a XWPFParagraph from the CTP object and then use the default apache-poi methods further.
...
CTTxbxContent ctTxbxContent = ctShape.addNewTextbox().addNewTxbxContent();
XWPFParagraph textboxparagraph = new XWPFParagraph(ctTxbxContent.addNewP(), (IBody)doc);
XWPFRun textboxrun = textboxparagraph.createRun();
textboxrun.setText("The TextBox text...");
textboxrun.setFontSize(24);
...

How can I save extra PowerPoint Chart information in an XML

In my PowerPoint Add-in that creates different charts, I am drawing some shapes and lines to highlight different data and do some basic functionality.
Now, when the user saves the Presentation, I need to save the information related to these lines and shapes, as well as some of my chart properties. In my R&D, I have found that data can be saved in XML format inside a .pptx file because its an XML based format.
I can save my custom data in an XML file inside .pptx file pro grammatically by using CustomXMLParts.
string xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<connectors xmlns=\"http://schemas.microsoft.com/vsto/samples\">" +
"<connectorLine>" +
"<connectorLineIndex>1</connectorLineIndex>" +
....
"</connectorLine>" +
"</connectors >";
Office.CustomXMLPart connectorXML = presentation.CustomXMLParts.Add(xmlString, missing);
This adds an XML in .pptx file.
Now, I am stuck. I need to read this XML file(and a couple of other XML files) when user opens the Presentation and draw the objects according to the data saved in the XML file.
How can I do this? Am I even doing it the right way? Thanks in advance for any help.

Solr: store Text Layout from extrected pdf with tika / extract request handler

i'm using solr 4 and the extract request handler to index pdf files, which works well.
The text from the pdf is stored in the index in oder to display/provide an text snipped with highlighting.
The problem is, that the layout of the stored text is lost in solrs stored fiels.
For example, if the pdf content is:
left text right text
2nd. line leftr text text at the right side
....the content of the stored field lookes like that:
left text right text
2nd. line leftr text text at the right side
On the other hand: if i extrat the pdf to text (using linux tool pdftotext) followed by indexing the textfile (instead the pdf) using the extract request hendler -> the stored field contains/includes the layout.
So the text snipped (and the content of the stored field in solr) lookes like that:
left text right text
2nd. line leftr text text at the right side
My Question: Is there a way to keept the layout also while indexing an pdf, not only an text file?
Apache Tika would extract all the text from the pdf and index the contents as a text file.
But Instead of using the ExtractHandler with Tika, you can always convert the pdf to text and get it index so that you have the text with layout and have search enabled over it.
You can also check if you can change the default handling of Apache Tika probably using PDFBox to use other converter which holds the text layout.