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

converting PDF files saved in a Stream Array to Tiff files

$
0
0
Hi,
I have a stream array that is holding 4 PDF Files as memorystreams.  How do I read and convert the contents of the stream array and output 1 tiff file?

Here is my code that is not working currently.

Thank you
Tad

 Aspose.Pdf.Generator.Pdf pdf2 = new Aspose.Pdf.Generator.Pdf();
            for (int i = 0; i < count; i++)
            {
                ///read the source text file
                //System.IO.TextReader tr = new StreamReader(pdfStreams[i]);

                ////Create a new section in the Pdf object
                Aspose.Pdf.Generator.Section sec2 = pdf2.Sections.Add();

                ////Create a new text paragraph and pass the text to its constructor as argument
                //Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text(tr.ReadToEnd());
                //sec1.Paragraphs.Add(t2);

                //Create an image object in the section
                Aspose.Pdf.Generator.Image image2 = new Aspose.Pdf.Generator.Image(sec2);

                //create new Bite Array 
                byte[] biteArray = new byte[pdfStreams.Length];
                //Read the entire stream 
                pdfStreams[i].Read(biteArray, 0, biteArray.Length);

                MemoryStream ms = new MemoryStream(biteArray);

                image2.ImageInfo.ImageStream = ms;
                //string location = pdfStreams[i].ToString();

                //Set the type of image using ImageFileType enumeration
                image2.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;

                //Add image object into the Paragraphs collection of the section
                sec2.Paragraphs.Add(image2);
              }


            Resolution resolution1 = new Resolution(300);

            // Create TiffSettings object
            TiffSettings tiffSettings = new TiffSettings();
            tiffSettings.Compression = CompressionType.None;
            tiffSettings.Depth = ColorDepth.Default;
            tiffSettings.Shape = ShapeType.Landscape;
            tiffSettings.SkipBlankPages = false;

            // Create TIFF device
            TiffDevice tiffDevice = new TiffDevice(resolution1, tiffSettings);

            Aspose.Pdf.Document pdffile = new Aspose.Pdf.Document(pdf2);
            tiffDevice.Process(pdffile, destfilepath + "output.tiff");

Aspose.PDF.KIT => Verify Digital Signature

$
0
0
Hello,

I want to verify a singed pdf file.

1) this is how i sing the pdf file
    Public Shared Sub SignPDFWithVisibleSignatureUsingAspose()
        Dim oCertificate As Certificate = New Certificate("testvcg.pfx", "test")
        Dim oPdfFileSignature As PdfFileSignature = New PdfFileSignature(oCertificate)
        oPdfFileSignature.BindPdf("test2.pdf")
        Dim oRec As System.Drawing.Rectangle = New System.Drawing.Rectangle(100, 100, 100, 100)
        oPdfFileSignature.Sign(1, "Approved", "Ludwig Ghislain", "Gent Belgium", True, oRec)
        oPdfFileSignature.Save("singed_valid.pdf")
        Console.WriteLine("has signature?" & oPdfFileSignature.IsContainSignature)
        Console.ReadLine()
    End Sub

2) this is how I read the singed file
    Public Shared Sub ValidateSingedPDFUsingAspose()
        Dim oCertificate As Certificate = New Certificate("testvcg.pfx", "test")
        Dim oPdfFileSignature As PdfFileSignature = New PdfFileSignature(oCertificate)
        oPdfFileSignature.BindPdf("singed_valid.pdf")
        Dim singatureAppearance As String = oPdfFileSignature.SignatureAppearance()
        Console.WriteLine("Contains singature?: " & oPdfFileSignature.IsContainSignature())
        Console.WriteLine("SignModel" & oPdfFileSignature.SignModel)
        Dim oList As ArrayList = oPdfFileSignature.GetSignNames()
        For I As Integer = 0 To oList.Count - 1
            Console.WriteLine("signature name:" & oList(I))
            Console.WriteLine("coverswholedocument:" & oPdfFileSignature.IsCoversWholeDocument(oList(I)))
            Console.WriteLine("revision:" & oPdfFileSignature.GetRevision(oList(I)))
            Console.WriteLine("verifysigned:" & oPdfFileSignature.VerifySigned(oList(I)))
            Console.WriteLine("reason:" & oPdfFileSignature.GetReason(oList(I)))
            Console.WriteLine("location:" & oPdfFileSignature.GetLocation(oList(I)))
            Console.WriteLine("datatime:" & oPdfFileSignature.GetDateTime(oList(I)))
        Next
        Console.WriteLine(oPdfFileSignature.SignModel.ToString)
        Console.ReadLine()
    End Sub


The Result:
has signature?False

Contains singature?: True
SignModelAdobe.PPKLite
signature name:Signature1
coverswholedocument:True
revision:1
verifysigned:False
reason:Approved
location:Gent Belgium
datatime:29/10/2008 11:49:09
Adobe.PPKLite


The problem:

The oPdfFileSignature.VerifySinged expects an parameter "signName" and returns a string.
The name of the singature is: "Singature1" as you can see above.
Is it possible to change that name? so the VerifySinged method can be true and I can assume the document is singed with the correct certificate?

thx in advance


Ludwig

Repeat more than one row in every page

$
0
0
Hi,

I am trying to generate a report that has more than 1 page, and on each page I want the first 2 rows to be repeated as the header of the table. I am using the following code snippet.

 Dim tab1 As Aspose.Pdf.Generator.Table = New Aspose.Pdf.Generator.Table()
 tab1.RepeatingRows = 2

The application is generated all reports, but I am only able to view the reports with one page. The reports with more than 1 page is corrupted and it says that the Adobe cannot support that version.

Could you please advice me on this issue.

Thanks!

Aspose.PDF.Net not working on Windows Server 2012

$
0
0
I have an issue where my web application use Aspose.PDF.Net to generate PDFs.  It works perfect on my development system and LocalHost website.  When publishing to my test server, the application fails.  I have check my IIS configuration to ensure that .Net has Full Trust.  License files have been deployed.  My development system is running Windows 7 and my test server is running Windows Server 2012.  

Are there any other configuration settings that I should be checking??

Open Password Protected File - Aspose.pdf for java

$
0
0
Hi,

I have a pdf file which is password protected (Specific Region is protected from editing), I am able to open the document using Adobe without providing password, but when I use Aspose.PDF to merge such a file, I get the following error.

com.aspose.pdf.internal.p344.z107: PdfFileInfo is not initialized. Use constructors with parameters or properties for initialization. - Reason Invalid password.

Can we merge pdf created with Editing Password to another pdf using Aspose. I remeber I have used Aspose.Word also and I was able to merge password protected (Editing) to an exisitng document.

Regards,

Table inside floating Box - IsBroken not working (which exceeds page height)

$
0
0
Hi,

This is what I am trying to do - 
I have to place the tables, text and images in absolute position.
So I have created floating box and placed the elements (Table/Image/Text) inside it.

Table content is dynamic and can span upto several pages. In that case table should be broken and displayed in new page along with header. 
If the table is placed outside floating box, this works fine (by setting IsBroken flag).

But I couldn't achieve the same, after placing the table inside FloatingBox.

Please advise ASAP.


(I can understand that the purpose of floating box is little different from what I am trying to achieve. But I need to place the elements in absolute position - Explicitly Set Top and Left. So I chose this option)

[Edit]
I am using Aspose.Pdf.Generator

Font Not Found

$
0
0
I have research this message and found numerous posts regarding this error.  However, the resolutions do not work with my situation.

I am using aspose.words .net 4.4 and aspose.pdf .net 10.1 running on Windows 7.

When I attempt to save the PDF I get the following error:
System.ApplicationException: Font '"' not found. Please make sure the customer font file is correctly set.

The word document is built from text boxes where data has been copied from a word document and pasted into these text boxes.  During this process, html code is generated that may not include the proper formatting.  

I am under the impression that a default font is used to prevent this error.  This is not happening and the error is generated.  How can I force a default font?

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

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

Merge ODF

$
0
0
We have  to merging PDF documents.Product related documents uploaded by admin in documents/files.Based on a selection of user (2 out of 10) , selected documents needs to be merged in single PDF. 
Has anybody done this previously? Is there any appexchange app available to do this?

Font name not recognized

$
0
0
Hello,

I have a problem with creating a PDF document with custom fonts. I attached both fonts and here is a short code snippet which demonstrates the problem:

            System.Drawing.Font winFont = new System.Drawing.Font("Humnst777 BT", 10);
            System.Diagnostics.Debug.WriteLine(winFont.FontFamily.Name);

            Aspose.Pdf.Text.Font font = FontRepository.OpenFont(@"C:\Windows\Fonts\HUM777N.TTF");
            System.Diagnostics.Debug.WriteLine(font.FontName);


The first WriteLine prints the following value on the console: Humnst777 BT. The second WriteLine produces a different output: Humanist 777 BT. A similar issue happens with the OCR font.

Obviously Aspose detects these fonts under a different name than Windows does. This must be the reason that the PDF export fails (see the attached sample code). No error is reported, but an empty file is produced (zero bytes).

I am using PDF library version 2015.01.12, which is quite new.

Of course I can do the name mappings on my own for these two fonts, but I am afraid that our customers will be facing the same problem sometime in the future. Is there a way to completely solve this issue?

Thank you in advance for your help,

Boris

Textbox with Justify not working when text contains a parameter

$
0
0
Hi

Is it by design or a bug that text justify works fine unless I put a parameter or other expression into the text?

Thanks,
Greg

converting PDF files saved in a Stream Array to Tiff files

$
0
0
Hi,
I have a stream array that is holding 4 PDF Files as memorystreams.  How do I read and convert the contents of the stream array and output 1 tiff file?

Here is my code that is not working currently.

Thank you
Tad

 Aspose.Pdf.Generator.Pdf pdf2 = new Aspose.Pdf.Generator.Pdf();
            for (int i = 0; i < count; i++)
            {
                ///read the source text file
                //System.IO.TextReader tr = new StreamReader(pdfStreams[i]);

                ////Create a new section in the Pdf object
                Aspose.Pdf.Generator.Section sec2 = pdf2.Sections.Add();

                ////Create a new text paragraph and pass the text to its constructor as argument
                //Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text(tr.ReadToEnd());
                //sec1.Paragraphs.Add(t2);

                //Create an image object in the section
                Aspose.Pdf.Generator.Image image2 = new Aspose.Pdf.Generator.Image(sec2);

                //create new Bite Array 
                byte[] biteArray = new byte[pdfStreams.Length];
                //Read the entire stream 
                pdfStreams[i].Read(biteArray, 0, biteArray.Length);

                MemoryStream ms = new MemoryStream(biteArray);

                image2.ImageInfo.ImageStream = ms;
                //string location = pdfStreams[i].ToString();

                //Set the type of image using ImageFileType enumeration
                image2.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;

                //Add image object into the Paragraphs collection of the section
                sec2.Paragraphs.Add(image2);
              }


            Resolution resolution1 = new Resolution(300);

            // Create TiffSettings object
            TiffSettings tiffSettings = new TiffSettings();
            tiffSettings.Compression = CompressionType.None;
            tiffSettings.Depth = ColorDepth.Default;
            tiffSettings.Shape = ShapeType.Landscape;
            tiffSettings.SkipBlankPages = false;

            // Create TIFF device
            TiffDevice tiffDevice = new TiffDevice(resolution1, tiffSettings);

            Aspose.Pdf.Document pdffile = new Aspose.Pdf.Document(pdf2);
            tiffDevice.Process(pdffile, destfilepath + "output.tiff");

Aspose.PDF.KIT => Verify Digital Signature

$
0
0
Hello,

I want to verify a singed pdf file.

1) this is how i sing the pdf file
    Public Shared Sub SignPDFWithVisibleSignatureUsingAspose()
        Dim oCertificate As Certificate = New Certificate("testvcg.pfx", "test")
        Dim oPdfFileSignature As PdfFileSignature = New PdfFileSignature(oCertificate)
        oPdfFileSignature.BindPdf("test2.pdf")
        Dim oRec As System.Drawing.Rectangle = New System.Drawing.Rectangle(100, 100, 100, 100)
        oPdfFileSignature.Sign(1, "Approved", "Ludwig Ghislain", "Gent Belgium", True, oRec)
        oPdfFileSignature.Save("singed_valid.pdf")
        Console.WriteLine("has signature?" & oPdfFileSignature.IsContainSignature)
        Console.ReadLine()
    End Sub

2) this is how I read the singed file
    Public Shared Sub ValidateSingedPDFUsingAspose()
        Dim oCertificate As Certificate = New Certificate("testvcg.pfx", "test")
        Dim oPdfFileSignature As PdfFileSignature = New PdfFileSignature(oCertificate)
        oPdfFileSignature.BindPdf("singed_valid.pdf")
        Dim singatureAppearance As String = oPdfFileSignature.SignatureAppearance()
        Console.WriteLine("Contains singature?: " & oPdfFileSignature.IsContainSignature())
        Console.WriteLine("SignModel" & oPdfFileSignature.SignModel)
        Dim oList As ArrayList = oPdfFileSignature.GetSignNames()
        For I As Integer = 0 To oList.Count - 1
            Console.WriteLine("signature name:" & oList(I))
            Console.WriteLine("coverswholedocument:" & oPdfFileSignature.IsCoversWholeDocument(oList(I)))
            Console.WriteLine("revision:" & oPdfFileSignature.GetRevision(oList(I)))
            Console.WriteLine("verifysigned:" & oPdfFileSignature.VerifySigned(oList(I)))
            Console.WriteLine("reason:" & oPdfFileSignature.GetReason(oList(I)))
            Console.WriteLine("location:" & oPdfFileSignature.GetLocation(oList(I)))
            Console.WriteLine("datatime:" & oPdfFileSignature.GetDateTime(oList(I)))
        Next
        Console.WriteLine(oPdfFileSignature.SignModel.ToString)
        Console.ReadLine()
    End Sub


The Result:
has signature?False

Contains singature?: True
SignModelAdobe.PPKLite
signature name:Signature1
coverswholedocument:True
revision:1
verifysigned:False
reason:Approved
location:Gent Belgium
datatime:29/10/2008 11:49:09
Adobe.PPKLite


The problem:

The oPdfFileSignature.VerifySinged expects an parameter "signName" and returns a string.
The name of the singature is: "Singature1" as you can see above.
Is it possible to change that name? so the VerifySinged method can be true and I can assume the document is singed with the correct certificate?

thx in advance


Ludwig

Repeat more than one row in every page

$
0
0
Hi,

I am trying to generate a report that has more than 1 page, and on each page I want the first 2 rows to be repeated as the header of the table. I am using the following code snippet.

 Dim tab1 As Aspose.Pdf.Generator.Table = New Aspose.Pdf.Generator.Table()
 tab1.RepeatingRows = 2

The application is generated all reports, but I am only able to view the reports with one page. The reports with more than 1 page is corrupted and it says that the Adobe cannot support that version.

Could you please advice me on this issue.

Thanks!

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?

java.lang.OutOfMemoryError: Java heap space Reading simple PDF

$
0
0
I am trying to convert a PDF pages to images just using the code from the documentation and I am getting a out of heap space error.
I have increased the JVM memory but I still get the error.

here is the code
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("input.pdf");

// Loop through all the pages of PDF file
for (int pageCount = 1; pageCount
{
// Create stream object to save the output image
java.io.OutputStream imageStream = new java.io.FileOutputStream("Converted_Image" + pageCount + ".jpg");


// Create Resolution object
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(300);
// Create JpegDevice object where second argument indicates the quality of resultant image
com.aspose.pdf.devices.JpegDevice jpegDevice = new com.aspose.pdf.devices.JpegDevice(resolution, 100);
// Convert a particular page and save the image to stream
jpegDevice.process(pdfDocument.getPages().get_Item(pageCount), imageStream);

// Close the stream
imageStream.close();
}



and this is the error.



Exception in thread "AgentThread: JavaAgent" java.lang.OutOfMemoryError: Java heap space
at java.lang.StringCoding.decode(StringCoding.java:505)
at java.lang.String.(String.java:241)
at java.util.jar.Manifest.parseName(Manifest.java:262)
at java.util.jar.Manifest.read(Manifest.java:216)
at java.util.jar.Manifest.(Manifest.java:62)
at java.util.jar.JarFile.getManifestFromReference(JarFile.java:170)
at java.util.jar.JarFile.getManifest(JarFile.java:153)
at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:944)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:465)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:451)
at java.net.URLClassLoader.access$300(URLClassLoader.java:79)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1038)
at java.security.AccessController.doPrivileged(AccessController.java:365)
at java.net.URLClassLoader.findClass(URLClassLoader.java:429)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:281)
at java.lang.ClassLoader.loadClass(ClassLoader.java:677)
at java.lang.ClassLoader.loadClass(ClassLoader.java:643)
at com.aspose.pdf.internal.p357.z2.(Unknown Source)
at com.aspose.pdf.internal.p597.z2.m1(Unknown Source)
at com.aspose.pdf.internal.p634.z8.(Unknown Source)
at com.aspose.pdf.internal.p631.z12.m1(Unknown Source)
at com.aspose.pdf.internal.p561.z6.(Unknown Source)
at com.aspose.pdf.internal.p598.z2.m1(Unknown Source)
at com.aspose.pdf.internal.p564.z7.m1(Unknown Source)
at com.aspose.pdf.devices.z1.m1(Unknown Source)
at com.aspose.pdf.devices.z1.m1(Unknown Source)
at com.aspose.pdf.devices.ImageDevice.m1(Unknown Source)
at com.aspose.pdf.devices.JpegDevice.processInternal(Unknown Source)
at com.aspose.pdf.devices.JpegDevice.process(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)

I am not sure if this is important but the PC running this code is not connected to the internet.

Also it is running an a IBM Notes client.

THanks
Viewing all 1038 articles
Browse latest View live