Quantcast
Channel: Aspose.Pdf Product Family
Viewing all 1038 articles
Browse latest View live

PDF to XML and XML to PDF conversion issue

$
0
0
Hi,

I have converted a pdf to xml using Aspose Pdf api and again I converted the xml to pdf back, during this xml to pdf conversion process, an empty pdf document is created without any actual content in it.

And also I would like to know during this conversion process will the generated pdf documents contains the same actual font settings?

Regards,
Dharmender


Unable to extract attachments from pdf document.

$
0
0
Dear Aspose Team,

Please find attached pdf file. I am using the below code to extract the attachments from a pdf document. But it is showing the embedded files count as 0.

var attachments =  pdfDocument.EmbeddedFiles;

Please let me know whether this is an issue inside Aspose.Pdf or not.

Thanks & Regards,
N.Murali Krishna.

Pdf to Image Conversion-generating black images

$
0
0
Hi,

when i try to convert a pdf doc page (specification-1.3) to image.The resulting images are black.

we are using Aspose.Pdf version 7.0.does it support versions below 1.4?

I'm using the below code.

private static void GenerateImageFromPDF(Int32 pageNumber, string inputFilePath, string outputFilepath)
        {
            System.Drawing.Size resize = new System.Drawing.Size(200, 300);
            Aspose.Pdf.License _licensePdf = new Aspose.Pdf.License();
            _licensePdf.SetLicense("Aspose.Total.lic");

            using (Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputFilePath))
            {
                
                pdfDocument.Validate("test.txt", Aspose.Pdf.PdfFormat.);
                Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(80);
                Aspose.Pdf.Devices.PngDevice pngDevice;
                pngDevice = new Aspose.Pdf.Devices.PngDevice(resize.Width, resize.Height);
                if (resize.Height == 0 || resize.Width == 0)
                {
                    pngDevice = new Aspose.Pdf.Devices.PngDevice(resolution);
                }
                else
                {
                    pngDevice = new Aspose.Pdf.Devices.PngDevice(resize.Width, resize.Height);
                }
                var directory = Path.GetDirectoryName(outputFilepath);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                // Convert a particular page and save the image to stream
                pngDevice.Process(pdfDocument.Pages[pageNumber], outputFilepath);

            }
        }

--
Thanks,
Lalitya

Export PDF pages as images

$
0
0
Hi Aspose team, is there any option that I loop through PDF document pages and export each of them as a separate image (any image format will work). Thanks, Oliver

Html to PDF is very slow

$
0
0
Hello

I was wondering if I can do something about the rendering time.

See attachments for test html files.
It takes about 5 seconds to render test1.html and about 80 seconds to render test2.html
The resulting pdf files are rendered OK, but it just takes too long.

My code is as follows: (Aspose.pdf.dll version 10.5.1.0)

var license = new License();
license.SetLicense(...path to license...);
var htmlLoadOptions = new HtmlLoadOptions { InputEncoding = "UTF8" };
var file = "d:\\test2.html";
var doc = new Aspose.Pdf.Document(file, htmlLoadOptions);
doc.Save(System.IO.Path.ChangeExtension(file, ".pdf"));

File size increasing while converting from pdf to pdf/A

$
0
0
Hi,
      When I am converting PDF to PDF/A, the size is increasing from 14 KB to 1859 KB, we are using License version "9.4.0.0",
Attached are  the Image

Please find My Code Snippet

 public static string ConvertPdfToPdfA(string file, string fileName, string destinationFolder)
        {
            try
            {
                var pdfADoc = new Aspose.Pdf.Document(file);
                pdfADoc.Convert("log.xml", PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);

                pdfADoc.OptimizeResources(new Document.OptimizationOptions()
                {
                    RemoveUnusedObjects = true,
                    RemoveUnusedStreams = true,
                    CompressImages = true,
                    UnembedFonts = false,
                    LinkDuplcateStreams = false,
                    ImageQuality = 10
                });
                pdfADoc.Save(destinationFolder + "\\" + fileName + ".pdf");
                return destinationFolder + "\\" + fileName + ".pdf";
            }
            catch (Exception exception)
            {

                return string.Empty;
            }

        }


Regards

Srikant Bal

Problems Reading Attachments from PDF

$
0
0
Hello ASPOSE,

I tried the code provided at http://www.aspose.com/docs/display/pdfnet/Get+All+Attachments+from+a+PDF+Document
But no attachment was found even I can see the attachment in Adobe.
The PDF was formerly created with ASPOSE.PDF.Generator. The aspose.pdf.dll version I use is 10.2.0.

Please tell me how I can access the attachment correctly.

Regards
Gerd

PS: the code I used
      // Open document      Document pdfDocument = new Document(@"c:\temp\DownloadablesWithAttachmentsTest.pdf");      // Get embedded files collection      EmbeddedFileCollection embeddedFiles = pdfDocument.EmbeddedFiles;      // Get count of the embedded files      Console.WriteLine("Total files : {0}"embeddedFiles.Count);      // Loop through the collection to get all the attachments      foreach (FileSpecification fileSpecification in embeddedFiles)      {        Console.WriteLine("Name: {0}"fileSpecification.Name);        Console.WriteLine("Description: {0}"fileSpecification.Description);        Console.WriteLine("Mime Type: {0}"fileSpecification.MIMEType);        // Check if parameter object contains the parameters        if (fileSpecification.Params != null)        {          Console.WriteLine("CheckSum: {0}"fileSpecification.Params.CheckSum);          Console.WriteLine("Creation Date: {0}"fileSpecification.Params.CreationDate);          Console.WriteLine("Modification Date: {0}"fileSpecification.Params.ModDate);          Console.WriteLine("Size: {0}"fileSpecification.Params.Size);        }        // Get the attachment and write to file or stream        byte[] fileContent = new byte[fileSpecification.Contents.Length];        fileSpecification.Contents.Read(fileContent, 0, fileContent.Length);        FileStream fileStream = new FileStream(fileSpecification.NameFileMode.Create);        fileStream.Write(fileContent, 0, fileContent.Length);        fileStream.Close();      }

TextFragment Position

$
0
0
Hi,
I am not very familiar with the internal structure of Pdf, so I may miss some points. 
I want to draw rectangle on an image created by the conversion of Pdf page. The code works fine for most of the documents but for some cases either box is not drawn or it is drawn on a wrong place. After a bit examine I've seen that the Position values of TextFragment object are besides the page width and height. For example for the first sample file, YIndent of the TextFragment's Position is 686.15, while Page.Rect.Height is 626.

I've attached the VS project and sample files. Could you please explain the issue I made.

Thank you

add text stamp crashing program getting error program stopped working

$
0
0
Hi team I have a requirement to run PDF add text stamp as a separate exe so that it will run in the back ground when called. I am running it as a win form with the form deleted. My project has a reference to Aspose.Pdf.dll. When the exe is called it crashes with the message program stopped working. I've determined that it is something in the code that I am using to add the text stamp. when I comment the code out it works. I've attached the code file. Please tell me what I am doing wrong.
Thanks.
Bill  

Field values missing or formatted incorrectly when printing PDF

$
0
0
Hello there,

I have attached a copy of the printed PDF and the file version. As you can see there are data fields in the print copy that are not formatted correctly and others that are blank.

The data is coming from an OLEDB connection to an SQL Server. I have included my code also.

The Original PDF we are filling was created using LiveCycle Designer 11.0, PDF version is 1.7, Adobe Extension Level 3 (Acrobat 9.x).

Can you shed some light on this?

Thanks

Mike

HTML to PDF Conversion Error

$
0
0
I am using Aspose Total for Java SDK to convert files.
When converting the attached Html file to pdf, I am getting the following error:

class com.aspose.pdf.internal.p344.z10: Value cannot be null.
Parameter name: rawHtml
com.aspose.pdf.internal.p225.z2.m1(Unknown Source)
com.aspose.pdf.internal.p211.z4.m2(Unknown Source)
com.aspose.pdf.internal.p211.z5.m1(Unknown Source)
com.aspose.pdf.internal.p211.z4.m3(Unknown Source)
com.aspose.pdf.internal.p211.z4.m3(Unknown Source)
com.aspose.pdf.internal.p211.z4.m1(Unknown Source)
com.aspose.pdf.internal.p211.z4.m1(Unknown Source)
com.aspose.pdf.internal.p214.z1.m1(Unknown Source)
com.aspose.pdf.z30.m1(Unknown Source)
com.aspose.pdf.ADocument.m1(Unknown Source)
com.aspose.pdf.ADocument.<init>(Unknown Source)
com.aspose.pdf.Document.<init>(Unknown Source)

Please let me know how to resolve this issue.
Thanks.

Centering Images

$
0
0
I'm attempting to center an image on a page, but as far as I can tell the HorizontalAlignment property is not having any effect.  The following ends up being left-aligned:

   Image image = new Image();
   image.File = @"c:\images\image.png";
   image.HorizontalAlignment = HorizontalAlignment.Center;
   pdf.Pages[1].Paragraphs.Add(image);

Is there anything else I should be doing to ensure the image is centered?

GDI+ error on Windows Server 2003

$
0
0

Hello,

I've got this error when running the attached project on a Windows Server 2003

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
   at System.Drawing.Image.SaveAdd(EncoderParameters encoderParams)
   at ‼.§‼.??()
   at Aspose.Pdf.Devices.TiffDevice.Process(Document document, Int32 fromPage, Int32 toPage, Stream output)
   at Aspose.Pdf.Devices.DocumentDevice.Process(Document document, Int32 fromPage, Int32 toPage, String outputFileName)
   at TEST_ASPOSE.PDF.Program.SplitToTifPdf(Stream stream, Int16 pageOffset) in
c:\dev\chomele\TEST\TEST_ASPOSE.PDF\TEST_ASPOSE.PDF\Program.cs:line 50

I'm using Aspose.PDF 9.5.0 and framework dotNet 4. For your information, running this program on Windows Server 2012, this error doesn't show up.

Any help appreciated,

Elisa.

 

TextBoxField Background Color Alpha

$
0
0
I am using Aspose.Pdf 10.5.1.  

When setting the Annotation.Characteristics.Background property, the alpha channel is ignored.  This is the case whether I set the property directly or use the FormFieldFacade class.  Indeed, when I inspect the property in debug mode, the alpha channel is set to 255, no matter what I attempt to set it to.

Here is some example code...

Without facades

using (var inputPdf = new FileStream(INPUTPDF, FileMode.Open, FileAccess.Read))
using (var outputPdf = new FileStream(OUTPUTPDF, FileMode.Create, FileAccess.Write))
using (var document = new Document(inputPdf))
{
foreach (var field in document.Form.Fields)
{
var textBoxField = field as TextBoxField;
if (textBoxField != null)
{
textBoxField.Characteristics.Background = System.Drawing.Color.FromArgb(100, 222, 228, 254); 
}                                    
}

document.Save(outputPdf);
}

With facades

using (var inputPdf = new FileStream(INPUTPDF, FileMode.Open, FileAccess.Read))
using (var outputPdf = new FileStream(OUTPUTPDF, FileMode.Create, FileAccess.Write))
using (var document = new Document(inputPdf))
using (var editor = new FormEditor(document))
{
var facade = new FormFieldFacade();
editor.Facade = facade;

facade.BackgroundColor = System.Drawing.Color.FromArgb(100, 222, 228, 254); 

foreach (var field in document.Form.Fields)
{
var textBoxField = field as TextBoxField;
if (textBoxField != null)
{
editor.DecorateField(field.FullName);
}                                    
}

document.Save(outputPdf);
}

In both cases, the result is that the background color of all the text box fields on the form is set to System.Drawing.Color(255, 222, 228, 254).

This makes it very difficult to mimic fields created using Adobe Acrobat. Is there any work around to this problem?  Am I missing something?

-Thanks

Timeout converting PDF to PNG

$
0
0
We are unable to convert the attached PDF to a PNG.  No error is coming up, just hangs during the conversion.

Issues saving a flattened PDF and concatenating PDF causing unstable system

$
0
0
We are unable to save PDF after it is flattened and same applies when concatenating it. It happens only in case of certain PDFs.

The two methods are
{Form form = new Form(inputStream);
                form.FlattenAllFields();
                form.Save(outputStream);}
and 

Concatenate(Stream[] inputStream, Stream outputStream);

Once a call to the dll is made from the code it seems to be stuck there without any results leading to unresponsive local development machines and  unresponsive/frozen  production systems until the application/server is restarted

We are currently using Aspose dll version  9.1.



Not able to write .png file in PDF

$
0
0
Hello,

In one of our application have pdf creation feature and in that we are writting multiple images in pdf , but when we select .png image then it throws error .
We have used the Aspose.Pdf for Android 1.6.0 


The code which we have done for this is as below:


com.aspose.pdf.Image m_logo = new com.aspose.pdf.Image();
m_logo.setFile(AppConstant.APP_STORAGE_DIRECTORY + File.separator + "PDFImages" + File.separator + "header.png");
 
 Page m_page = m_doc.getPages().add();
 Table m_banner = new Table();
   

  m_page.getParagraphs().add(m_banner);   
  m_banner.setColumnWidths("600");
  Row m_row = m_banner.getRows().add();
  m_row.isRowBroken(true);
  com.aspose.pdf.Cell m_cell2 = m_row.getCells().add();
  m_cell2.getParagraphs().add(m_logo);
Please let us know what we are doing wrong?

PdfFileSecurity adding user password when non supplied

$
0
0
Using PdfFileSecurity's method SetPrivilege(null, null. DocumentPrivilege) sets an owner password.
I remember testing it a few months ago and it did not set a password which means sometime in the last few months the behaviour changed. 
further more, what password is it setting if the input password is null??? 

"Object reference not set to an instance of an object" from PDF Cloud

$
0
0
I am trying to fill a PDF form I have uploaded to cloud storage. I can successfully get the form fields and values and download the PDF file itself through the API. However, I get "Object reference not set to an instance of an object" when issuing a PUT request to the service to fill out the form.

I am not sure what the problem is or how to get more details. Any help is appreciated.

Possible PDF encryption bug or documentation clarification needed

$
0
0
There seems to be a bug in the Aspose.Pdf.Facades.PdfFileSecurity class or the documentation. According to the documentation, the code snippet below is supposed to encrypt the PDF document:
using Aspose.Pdf.Facades;

const string path = @"C:\path\to\test.pdf";

using (var security = new PdfFileSecurity())
using (var stream = new MemoryStream(File.ReadAllBytes(path)))
{
    security.BindPdf(stream);
    security.EncryptFile("password", null, DocumentPrivilege.Print, KeySize.x256, Algorithm.AES);
    security.Save(path);
}
The resulting PDF does not seem to have its contents encrypted (maybe just the metadata is encrypted?). Adobe Acrobat prompts for the password on open, but other viewers (most notably the viewer on iOS and some Android viewers) display the PDF without prompting for a password. However, if you use the Aspose.Pdf.Document class to encrypt the document, it does seem to encrypt the entire document: 
using Aspose.Pdf;

const string path = @"C:\path\to\test.pdf";

var document = new Document(path);
document.Encrypt("password", null, Permissions.PrintDocument, CryptoAlgorithm.AESx256);
document.Save(path);
The resulting PDF does prompt for a password on all viewers we have tested with so far (or fails entirely on some mobile viewers that do not support PDF encryption). This seems like a pretty serious problem. PdfFileSecurity.EncryptFile() should encrypt the entire contents of the PDF. If not, at a minimum, the documentation should be updated to make it clear that it does not encrypt the actual contents of the file.
Viewing all 1038 articles
Browse latest View live