public override void Convert(FileInfo source, FileInfo target) { Pdf pdf = new Pdf(); Section section = pdf.Sections.Add(); var image = new Image(section); section.Paragraphs.Add(image); image.ImageInfo.File = source.FullName; image.ImageInfo.ImageFileType = GetImageFileType(source); image.ImageInfo.Title = source.Name; if (image.ImageWidth > image.ImageHeight) { FlipToLandscapeOrientation(section); } pdf.Save(target.FullName); }
Setting page orientation of generated PDF based on width and height of inserted image
Images converted from PDF->TIFF are having black background color instead of white in mspaint and microsoftoffice image tools
We recently purchased Aspose PDF component, by using below code snippet PDF files are converted to TIFF image.
Converted Tiff images –
1) Images are legitimate when it opens by using “IrfanImage”, “Microsoft office Document Imaging” tools. (Background color is : white and Text color is Black)
2) Same images when it opens by using “mspaint”, “Windows picture & Fax Viewer” tool – Image background coming in Black and Text in White color. Actually images suppose to be having white background and black text.
We would need a quick solution to view converted images uniformly in all image viewing tools. We appreciate quick response and solution.
Attached are:
1) Original PDF file.( 4831 EBDRTransactionAmountDiffersForm.pdf)
2) 4831 EBDRTransactionAmountDiffersForm_AsposeConverted.tif converted one.
Environment: JRE 7, OS: Linux and Windows.
Thanks
Raghu
Code Snippet:
SimpleDateFormat dateForamt=new SimpleDateFormat("dd-MM-yy:HH:mm:ss");
System.out.println("Image Conversion Start"+ dateForamt.format(System.currentTimeMillis()));
//Open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("C:\\ImageConversion\\Pdf\\ImageConversionNewtry\\EBDResolutionProcessForm(8).pdf");
//Create stream object to save the output image
java.io.OutputStream imageStream = new java.io.FileOutputStream("C:\\ImageConversion\\Pdf\\ImageConversionNewtry\\EBDResolutionProcessForm(8)_Converted.tif");
//Create Resolution object
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(200);
// instantiate TiffSettings object
com.aspose.pdf.devices.TiffSettings tiffSettings = new com.aspose.pdf.devices.TiffSettings();
// set the compression of resultant TIFF image
tiffSettings.setCompression(com.aspose.pdf.devices.CompressionType.CCITT4);
// set the color depth for resultant image
tiffSettings.setDepth(com.aspose.pdf.devices.ColorDepth.Format1bpp);
// skip blank pages while rendering PDF to TIFF
tiffSettings.setSkipBlankPages(false);
//Create TiffDevice object with particular resolution
com.aspose.pdf.devices.TiffDevice tiffDevice = new com.aspose.pdf.devices.TiffDevice(resolution,tiffSettings);
//Convert a particular page (Page 1) and save the image to stream
tiffDevice.process(pdfDocument,1,1, imageStream);
//Close the stream
imageStream.close();
dateForamt=new SimpleDateFormat("dd-MM-yy:HH:mm:ss");
System.out.println("After Save IMAGE"+ dateForamt.format(System.currentTimeMillis()));
Issue with getCharacterSpacing() and getLineSpacing() in Aspose.pdf for Java
NullPointerException in the Form.importXml (First Time Only)
Hi
there,
Aspose
pdf version - aspose-pdf-10.3.0.jar
Platform
– Fuse Windows, Fuse Linux
Document pdf = new Document(pdftemplateName);
Formform = new Form();
form.bindPdf(pdf);
InputStream xmlInputStream =
xml input stream
form.importXml(xmlInputStream);
xmlInputStream.close();
ByteArrayOutputStreambObj = new
ByteArrayOutputStream();
form.save(bObj);
byte[] byteArray = bObj.toByteArray();
The first time this code get executed we get the following
null pointer exception. Successive runs of this method works for the same input
xml.
java.lang.NullPointerException
at com.aspose.pdf.internal.p359.z32.m1(Unknown Source)
at com.aspose.pdf.internal.p361.z2.m1(Unknown Source)
at com.aspose.pdf.internal.p575.z11.m4(Unknown Source)
at com.aspose.pdf.internal.p575.z11.m7(Unknown Source)
at com.aspose.pdf.internal.p575.z11.m3(Unknown Source)
at com.aspose.pdf.internal.p575.z8.m1(Unknown Source)
at com.aspose.pdf.internal.p576.z12.m4(Unknown Source)
at com.aspose.pdf.internal.p576.z7.<init>(Unknown Source)
at com.aspose.pdf.internal.p576.z9.<init>(Unknown Source)
at com.aspose.pdf.internal.p576.z12.<init>(Unknown Source)
at com.aspose.pdf.internal.p575.z8.m1(Unknown Source)
at com.aspose.pdf.internal.p578.z27.m28(Unknown Source)
at com.aspose.pdf.internal.p578.z27.m1(Unknown Source)
at com.aspose.pdf.internal.p578.z29.m1(Unknown Source)
at com.aspose.pdf.internal.p578.z27.m1(Unknown Source)
at com.aspose.pdf.internal.p580.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p579.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p580.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p580.z1.m2(Unknown Source)
at com.aspose.pdf.TextBoxField.m2(Unknown Source)
at com.aspose.pdf.WidgetAnnotation.m1(Unknown Source)
at com.aspose.pdf.Field.updateAppearances(Unknown Source)
at com.aspose.pdf.Field.m6(Unknown Source)
at com.aspose.pdf.Field.setValue(Unknown Source)
at com.aspose.pdf.TextBoxField.setValue(Unknown Source)
at com.aspose.pdf.facades.AForm.m2(Unknown Source)
at com.aspose.pdf.facades.AForm.importXml(Unknown Source)
at com.aspose.pdf.facades.Form.importXml(Unknown Source)
Input xml:
<fieldsxmlns:docfun="http://wwww.connecture.com/integration/docgen"
xmlns:dyn="http://exslt.org/dynamic"xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:gsp="http://groovy.codehaus.org/2005/gsp">
<field name="Applicant_Signature">
<value>PrimaryFName, PrimaryLName</value>
</field>
</fields>
Aspose XFDF to PDF conversion
Set Characters per horizontal and vertical inch
Losing layers when converting
FloatingBox is postioned on next page
your banckle chat asked me to redirect my problem to the forum.
I looking for a workaround of following problem, or maybe I'm doing something wrong.
I put Text into Table.Cell.
I flag some of the Texts with a paragraph relative FloatingBox at the right margin.
The FloatingBox is the successor Paragraph of the upper Table.
I observe that if the content of the cell touches the lower margin, the floating box seems to displayed on the right vertical position on the next page. You can observe this in the table of chapter 1.2.4 in the attached PDF.
I can share only my document and the floating box code which is creating all images in FloatingBoxes on the right margin.
private Paragraph GenerateStatusBoxRight(IPDFSection section, Paragraph parent, SizeF statusIconSize) { FloatingBox statusBoxRight = new FloatingBox(section.Section.PageInfo.Margin.Right, statusIconSize.Height + parent.Margin.Top); section.Section.Paragraphs.Add(statusBoxRight); statusBoxRight.PositioningType = PositioningType.ParagraphRelative; statusBoxRight.BoxVerticalPositioning = BoxVerticalPositioningType.Paragraph; statusBoxRight.ReferenceParagraphID = parent.ID; statusBoxRight.BoxHorizontalPositioning = BoxHorizontalPositioningType.Page; statusBoxRight.BoxHorizontalAlignment = BoxHorizontalAlignmentType.Right; Image image = StatusDisplay.StatusToImage(myReportItemStatus.Status, false); image.ImageInfo.Alignment = AlignmentType.Center; image.Margin.Top = parent.Margin.Top; statusBoxRight.Paragraphs.Add(image); #if ! SHOWTABLES statusBoxRight.Border = new BorderInfo((int) BorderSide.All, new Aspose.Pdf.Generator.Color("MediumBlue"));#endif return statusBoxRight; }I'm using aspose.pdf 10.5.0.0
Converting HTML to PDF by saving to MemoryStream
I'm trying to convert an Html- into a PDF document, but no matter which approach I tried, I'm getting one of these errors:
You are in direct-to-file mode,please use Close() instead of Save(). (Pdf pdf = new Pdf(), then BindToHtml and save to MemoryStream)
OR
Input stream for html data must be FileStream (Document pdfDocument = new Document(memoryStream, htmlOptions))
The HTML is converted into a byte array, written into a MemoryStream, should now be converted to PDF by creating Document/Pdf saving into a new MemoryStream and finally returned as a byte array to be stored in SharePoint.
I'm using 7.9.0.0 and it is not possibly to save the PDF to a harddrive.
The tricky part seems to be that I get a byte array and want to save the PDF to a MemoryStream...
I appreciate any help.
Re: PDFANDROID-176 (Text is not bold, line isn't seen)
PDF-png: Yellow icon that indicates there is a comment in the png but not exist in original PDF
Replace text is now working aspose.pdf java
I was trying to replace the text using pdfContentEditor and also with TextFragmentAbsorber in the existing pdf file.
After replacing the text, i could see only few chars displayed(i.e. many characters are missing) in the updated pdf file.
Please let me know if anything missing during the replace text.
below is the code snippet am using for this.
com.aspose.pdf.facades.PdfContentEditor pdfContentEditor = new com.aspose.pdf.facades.PdfContentEditor();
pdfContentEditor.bindPdf(doc);
pdfContentEditor.replaceText("#UPPER LETTERS1#",1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
pdfContentEditor.replaceText("#lower letters2#",1, "abcdefghijklmnopqrstuvwxyz");
pdfContentEditor.save(outFile);
Note: When I copy the text from pdf, and paste in any editor, am able to see all characters.
Thanks,
Shivaji
Pdf image replace JBIG2
Which function should I use to get whether there is a XFA form in my PDF document?
Issues with flattening a PDF
I tried calling Form.flattenAllFields() per the documentation, as well as grabbing all the fields, iterating through them and calling Form.flattenField() directly (which flattenAllFields() probably does internally).
Another potential problem is performance. The flattening process is really slow. I don't know if there are some ways to speed this up. I was thinking of getting the field list then calling Form.flattenField() using multiple threads, I just don't know if the API can handle concurrent flattenField calls.
Images converted from PDF->TIFF are having black background color instead of white in mspaint and microsoftoffice image tools
We recently purchased Aspose PDF component, by using below code snippet PDF files are converted to TIFF image.
Converted Tiff images –
1) Images are legitimate when it opens by using “IrfanImage”, “Microsoft office Document Imaging” tools. (Background color is : white and Text color is Black)
2) Same images when it opens by using “mspaint”, “Windows picture & Fax Viewer” tool – Image background coming in Black and Text in White color. Actually images suppose to be having white background and black text.
We would need a quick solution to view converted images uniformly in all image viewing tools. We appreciate quick response and solution.
Attached are:
1) Original PDF file.( 4831 EBDRTransactionAmountDiffersForm.pdf)
2) 4831 EBDRTransactionAmountDiffersForm_AsposeConverted.tif converted one.
Environment: JRE 7, OS: Linux and Windows.
Thanks
Raghu
Code Snippet:
SimpleDateFormat dateForamt=new SimpleDateFormat("dd-MM-yy:HH:mm:ss");
System.out.println("Image Conversion Start"+ dateForamt.format(System.currentTimeMillis()));
//Open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("C:\\ImageConversion\\Pdf\\ImageConversionNewtry\\EBDResolutionProcessForm(8).pdf");
//Create stream object to save the output image
java.io.OutputStream imageStream = new java.io.FileOutputStream("C:\\ImageConversion\\Pdf\\ImageConversionNewtry\\EBDResolutionProcessForm(8)_Converted.tif");
//Create Resolution object
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(200);
// instantiate TiffSettings object
com.aspose.pdf.devices.TiffSettings tiffSettings = new com.aspose.pdf.devices.TiffSettings();
// set the compression of resultant TIFF image
tiffSettings.setCompression(com.aspose.pdf.devices.CompressionType.CCITT4);
// set the color depth for resultant image
tiffSettings.setDepth(com.aspose.pdf.devices.ColorDepth.Format1bpp);
// skip blank pages while rendering PDF to TIFF
tiffSettings.setSkipBlankPages(false);
//Create TiffDevice object with particular resolution
com.aspose.pdf.devices.TiffDevice tiffDevice = new com.aspose.pdf.devices.TiffDevice(resolution,tiffSettings);
//Convert a particular page (Page 1) and save the image to stream
tiffDevice.process(pdfDocument,1,1, imageStream);
//Close the stream
imageStream.close();
dateForamt=new SimpleDateFormat("dd-MM-yy:HH:mm:ss");
System.out.println("After Save IMAGE"+ dateForamt.format(System.currentTimeMillis()));
Render to Graphic Context
I'm currently evaluating your products in order to integrate different document formats into our reporting solution.
In Aspose Words a method RenderToScale exists which can be used to render to System.Drawing.Graphics.
This is very convenient for integrating the tool into a report generator.
Unfortunately, Pdf lack this functionality.
Is it not possible to render to a Graphics context?
Could you add this functionality in a future release?
I already posted the same request to the Aspose.Total forum and the team added the feature to Cells. See:
http://www.aspose.com/community/forums/thread/638102/render-to-graphic-context.aspx
If I could get the same functionality for the Pdf component, I could buy the whole package.
Best Regards,
Raphael
PdfFileSecurity adding user password when non supplied
PDF Bookmarks Generating in Wrong Order
Multilinetext + font auto + ImportXFDF = Font size MAX
l_pdfForm.Save("c:\temp\TestForm_FillField_result.pdf")
- TestForm.pdf (base PDF Form used as the template)
- TestForm_data.xfdf (XFDF data to be used for the form merge)
- TestForm_ImportXFDF_result.pdf (Result of Code Sample 1)
- TestForm_FillField_result.pdf (Result of Code Sample 2)