working on it ...

Filters

Explore Public Snippets

Sort by

Found 201k snippets matching: pdf

    public by antlong  489222  15  7  1

    Extract JPG images from a PDF

    A command line tool to extract jpg images from pdf files.
    #!/usr/bin/env python
    import sys
    
    
    def main():
        """Extract JPG's from PSD's.
        
        Usage:
          python extract.py filename.pdf
        
        Note:
          All extracted images will be saved to the directory 
          the script is initialized in.
        """
        try:
            pdf = file(sys.argv[1], "rb").read()
        except Exception:
            print "Usage: `python extract.py filename.pdf`"
            return
    
        startmark, endmark = "\xff\xd8", "\xff\xd9"
        startfix, endfix, i, njpg = 0, 2, 0, 0
    
        while True:
            istream = pdf.find("stream", i)
            if istream < 0:
                break
            istart = pdf.find(startmark, istream, istream+20)
            if istart < 0:
                i = istream+20
                continue
            iend = pdf.find("endstream", istart)
            if iend < 0:
                raise Exception("Couldn't find end of stream.")
            iend = pdf.find(endmark, iend-20)
            if iend < 0:
                raise Exception("Couldn't find end of JPG.")
         
            istart += startfix
            iend += endfix
            jpg = pdf[istart:iend]
            with open("jpg%d.jpg" % njpg, "wb") as _f:
                _f.write(jpg)
            njpg += 1
            i = iend
    
        print "Extracted %s JPG files." % njpg
    
    main()
    

    public by johansonkatherine  219713  1  6  2

    C# Code Sample to Replace Multiple Texts inside PDF File Using Cloud API

    The following code sample shows how developers can replace multiple texts in a single API call in a PDF file using Aspose.Pdf for Cloud API in their applications. Developers can use Aspose REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
    AsposeApp.AppSID  = "77***********************************";
    AsposeApp.AppKey = "9a*******************************";
    
    //build URI
    stringstrURI = "http://api.aspose.com/v1.1/pdf/test.pdf/replaceTextList";
    
    //sign URI
    stringsignedURI = Utils.Sign(strURI);
    
    //build JSON to post
    TextReplace textReplace1 = new TextReplace();
    textReplace1.OldValue = "[!firm!]";
    textReplace1.NewValue = "Aspose";
    textReplace1.Regex = "false";
    
    //build JSON to post
    TextReplace textReplace2 = new TextReplace();
    textReplace2.OldValue = "[!client!]";
    textReplace2.NewValue = "Mark";
    textReplace2.Regex = "false";
    
    MultipleTextReplacestextReplaces = new MultipleTextReplaces();
    textReplaces.TextReplaces = new TextReplace[] { textReplace1, textReplace2 };
    stringstrJSON = JsonConvert.SerializeObject(textReplaces);
    Console.Write(strJSON);
    Utils.ProcessCommand(signedURI, "POST", strJSON);
    
    //build URI
    strURI = "http://api.aspose.com/v1.1/storage/file/test.pdf";
    
    //sign URI
    signedURI = Utils.Sign(strURI);
    
    Stream responseStream = Utils.ProcessCommand(signedURI, "GET");
    using (Stream fileStream = System.IO.File.OpenWrite(@"test.pdf"))
    {
    Utils.CopyStream(responseStream, fileStream);
    }
    responseStream.Close();
    
    //Following are required classes
    public class MultipleTextReplaces
        {
    publicTextReplace[] TextReplaces { get; set; }
        }
    public class TextReplace
        {
    publicTextReplace() { }
    
    public string OldValue { get; set; }
    public string NewValue { get; set; }
    public string Regex { get; set; }
    
        }
    

    public by sherazam  2694  8  5  0

    How to Convert Large Text Files to PDF inside .NET Applications

    This technical tip shows how to convert a text file to PDF inside .NET applications. We are often asked if we can quickly provide some code which can accomplish this task and save them the effort of going through the documentation. So for the benefit of everyone, we present here a simple example which can be used as it is to easily and efficiently
    // Enter here the actual content of the snippet.            
    //Please take a look over the following code snippet for converting a text file to PDF
    
    //[C# Code Sample]
     
    
    //read the source text file
    System.IO.TextReader tr = new StreamReader("test.txt");
    
    //Instantiate Pdf pbject by calling its empty constructor
    Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
    
    //Create a new section in the Pdf object
    Aspose.Pdf.Generator.Section sec1 = pdf1.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);
    
    pdf1.Save("test.Pdf");
    
    //[VB.NET Code Sample]
     
    
    Dim tr As System.IO.TextReader = New StreamReader("test.txt")
    
    'Instantiate Pdf pbject by calling its empty constructor
    Dim pdf1 As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()
    
    'Create a new section in the Pdf object
    Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
    
    'Create a new text paragraph and pass the text to its constructor as argument
    Dim t2 As Aspose.Pdf.Generator.Text = New Aspose.Pdf.Generator.Text(tr.ReadToEnd())
    
    sec1.Paragraphs.Add(t2)
    
    pdf1.Save("test.Pdf")
    
    //Converting Large Text files to PDF
    
    //[C# Code Sample]
     
    
    //Instantiate Pdf pbject by calling its empty constructor
    Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
    //Create a new section in the Pdf object
    Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
    
    //Specify the location of input text file
    String FILE_NAME = "d:/pdftest/LargeText.txt";
    
    if (File.Exists(FILE_NAME))
       {
           
        System.IO.TextReader objReader =  new System.IO.StreamReader(FILE_NAME);
        // Read the file till the end of the file has come
        do 
        {
         //Create a new text paragraph & pass text to its constructor as argument
         Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text(objReader.ReadLine());
         // add the text object to paragraphs collection of section
         sec1.Paragraphs.Add(t2);
    
         // Read till the end of file
         }while(objReader.Peek() != -1);
    
       // Close the StreamReader object
       objReader.Close();
       }
       else
       MessageBox.Show("File Does Not Exist");
        
    // Save the PDF file
    pdf1.Save("d:/pdftest/large_textfile.pdf");
    
    //[VB.NET Code Sample]
     
    
    'Instantiate Pdf pbject by calling its empty constructor
    Dim pdf1 As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()
    
    'Create a new section in the Pdf object
    Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
    
    ' Specify the location of input text file
    Dim FILE_NAME As String = "d:/pdftest/LargeText.txt"
    
    If System.IO.File.Exists(FILE_NAME) = True Then
    
        Dim objReader As New System.IO.StreamReader(FILE_NAME)
        ' Read the file till the end of the file has come
        Do While objReader.Peek() <> -1
            'Create a new text paragraph and pass text to its constructor as argument
            Dim t2 As Aspose.Pdf.Generator.Text = New Aspose.Pdf.Generator.Text(objReader.ReadLine())
            ' add the text object to paragraphs collection of section
            sec1.Paragraphs.Add(t2)
        Loop
        ' Close the StreamReader object
        objReader.Close()
    Else
        MsgBox("File Does Not Exist")
    End If
    
    ' Save the PDF file
    pdf1.Save("d:/pdftest/large_textfile.pdf")
    
    

    public by sherazam  2774  3  6  0

    How to Extract Text from PDF Documents Based on Columns inside .NET Apps

    // Enter here the actual content of the snippet.            //The following code snippet shows the steps to reduce text size and then try extracting text from PDF document.
    
    //[C# Code Sample]
     
    
    string path = "D:\\Temp\\";
    InitLicense();
    Document pdfDocument = new Document(path + "net_New-age NED's.pdf");
    
    TextFragmentAbsorber tfa = new TextFragmentAbsorber();
    pdfDocument.Pages.Accept(tfa);
    TextFragmentCollection tfc = tfa.TextFragments;
    foreach (TextFragment tf in tfc)
    {
        //need to reduce font size at least for 70%
        tf.TextState.FontSize = tf.TextState.FontSize * 0.7f;
    }
    Stream st = new MemoryStream();
    pdfDocument.Save(st);
    pdfDocument = new Document(st);
    
    TextAbsorber textAbsorber = new TextAbsorber();
    pdfDocument.Pages.Accept(textAbsorber);
    String extractedText = textAbsorber.Text;
    textAbsorber.Visit(pdfDocument);
    
    System.IO.File.WriteAllText(path + "Extracted.txt", extractedText);
    
    // [VB.NET Code Sample]
     
    
    Dim path As String = "D:\\Temp\\"
    ' instantiate Document object 
    Dim pdfDocument As Document = New Document(path + "net_New-age NED's.pdf")
    
    Dim tfa As Aspose.Pdf.Text.TextFragmentAbsorber = New Aspose.Pdf.Text.TextFragmentAbsorber()
    pdfDocument.Pages.Accept(tfa)
    Dim tfc As Aspose.Pdf.Text.TextFragmentCollection = tfa.TextFragments
    For Each tf As Aspose.Pdf.Text.TextFragment In tfc
    
        ' need to reduce font size at least for 70%
        tf.TextState.FontSize = tf.TextState.FontSize * 0.7F
    Next
    ' create temporary stream object
    Dim st As Stream = New MemoryStream()
    ' save PDF file with reduced font size
    pdfDocument.Save(st)
    ' Instantiate Document object with stream instance
    pdfDocument = New Document(st)
    
    Dim textAbsorber As Aspose.Pdf.Text.TextAbsorber = New Aspose.Pdf.Text.TextAbsorber()
    pdfDocument.Pages.Accept(textAbsorber)
    Dim extractedText As String = textAbsorber.Text
    textAbsorber.Visit(pdfDocument)
    
    System.IO.File.WriteAllText(path + "Extracted.txt", extractedText)
     
    //Second approach - Using ScaleFactor
    
    //[C# Code Sample]
     
    
    Document pdfDocument = new Document(inputFile);
    
    TextAbsorber textAbsorber = new TextAbsorber();
    textAbsorber.ExtractionOptions = new TextExtractionOptions(TextExtractionOptions.TextFormattingMode.Pure);
    //Setting scale factor to 0.5 is enough to split columns in the majority of documents
    //Setting of zero allows to algorithm choose scale factor automatically
    textAbsorber.ExtractionOptions.ScaleFactor = 0.5; /* 0; */
    pdfDocument.Pages.Accept(textAbsorber);
    String extractedText = textAbsorber.Text;
    
    System.IO.File.WriteAllText(outFile, extractedText);
     
    // [VB.NET Code Sample]
     
    
    Dim pdfDocument As Document = New Document(inputFile)
    
    Dim textAbsorber As Aspose.Pdf.Text.TextAbsorber = New Aspose.Pdf.Text.TextAbsorber()
    textAbsorber.ExtractionOptions = New TextExtractionOptions(TextExtractionOptions.TextFormattingMode.Pure)
    'Setting scale factor to 0.5 is enough to split columns in the majority of documents
    'Setting of zero allows to algorithm choose scale factor automatically
    textAbsorber.ExtractionOptions.ScaleFactor = 0.5 ' 0;
    pdfDocument.Pages.Accept(textAbsorber)
    Dim extractedText As String = textAbsorber.Text
    
    System.IO.File.WriteAllText(outFile, extractedText)
    

    public by sherazam  4301  5  6  0

    How to Convert JPEG, PNG, BMP, EMF, WMF & GIF Images to PDF in .NET Apps

    // Enter here the actual content of the snippet.            
    // Convert single frame JPEG, PNG, BMP & Multi-frame TIF or GIF images to PDF
    
    //[C# Code Sample]
    
    // // For complete examples and data files, please go to https://github.com/asposewords/Aspose_Words_NET
    // The path to the documents directory.
    string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
    
    ConvertImageToPdf(dataDir + "Test.jpg", dataDir + "TestJpg_out_.pdf");
    ConvertImageToPdf(dataDir + "Test.png", dataDir + "TestPng_out_.pdf");
    ConvertImageToPdf(dataDir + "Test.wmf", dataDir + "TestWmf_out_.pdf");
    ConvertImageToPdf(dataDir + "Test.tiff", dataDir + "TestTif_out_.pdf");
    ConvertImageToPdf(dataDir + "Test.gif", dataDir + "TestGif_out_.pdf");
    
    //[VB Code Sample]
    
    ' For complete examples and data files, please go to https://github.com/asposewords/Aspose_Words_NET
    ' The path to the documents directory.
    Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
    
    ConvertImageToPdf(dataDir & Convert.ToString("Test.jpg"), dataDir & Convert.ToString("TestJpg_out_.pdf"))
    ConvertImageToPdf(dataDir & Convert.ToString("Test.png"), dataDir & Convert.ToString("TestPng_out_.pdf"))
    ConvertImageToPdf(dataDir & Convert.ToString("Test.wmf"), dataDir & Convert.ToString("TestWmf_out_.pdf"))
    ConvertImageToPdf(dataDir & Convert.ToString("Test.tiff"), dataDir & Convert.ToString("TestTiff_out_.pdf"))
    ConvertImageToPdf(dataDir & Convert.ToString("Test.gif"), dataDir & Convert.ToString("TestGif_out_.pdf"))
    
    
    //Using ConvertImageToPdf method
    
    //[C# Code Sample]
     
    
    // For complete examples and data files, please go to https://github.com/asposewords/Aspose_Words_NET
    // Create Aspose.Words.Document and DocumentBuilder. 
    // The builder makes it simple to add content to the document.
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    
    // Read the image from file, ensure it is disposed.
    using (Image image = Image.FromFile(inputFileName))
    {
        // Find which dimension the frames in this image represent. For example 
        // the frames of a BMP or TIFF are "page dimension" whereas frames of a GIF image are "time dimension". 
        FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]);
    
        // Get the number of frames in the image.
        int framesCount = image.GetFrameCount(dimension);
    
        // Loop through all frames.
        for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)
        {
            // Insert a section break before each new page, in case of a multi-frame TIFF.
            if (frameIdx != 0)
                builder.InsertBreak(BreakType.SectionBreakNewPage);
    
            // Select active frame.
            image.SelectActiveFrame(dimension, frameIdx);
    
            // We want the size of the page to be the same as the size of the image.
            // Convert pixels to points to size the page to the actual image size.
            PageSetup ps = builder.PageSetup;
            ps.PageWidth = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution);
            ps.PageHeight = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution);
    
            // Insert the image into the document and position it at the top left corner of the page.
            builder.InsertImage(
                image,
                RelativeHorizontalPosition.Page,
                0,
                RelativeVerticalPosition.Page,
                0,
                ps.PageWidth,
                ps.PageHeight,
                WrapType.None);
        }
    }
    
    // Save the document to PDF.
    doc.Save(outputFileName);
     
    //[VB.NET Code Sample]
     
    
    ' For complete examples and data files, please go to https://github.com/asposewords/Aspose_Words_NET
    ' Create Aspose.Words.Document and DocumentBuilder. 
    ' The builder makes it simple to add content to the document.
    Dim doc As New Document()
    Dim builder As New DocumentBuilder(doc)
    
    ' Read the image from file, ensure it is disposed.
    Using image__1 As Image = Image.FromFile(inputFileName)
        ' Find which dimension the frames in this image represent. For example 
        ' the frames of a BMP or TIFF are "page dimension" whereas frames of a GIF image are "time dimension". 
        Dim dimension As New FrameDimension(image__1.FrameDimensionsList(0))
    
        ' Get the number of frames in the image.
        Dim framesCount As Integer = image__1.GetFrameCount(dimension)
    
        ' Loop through all frames.
        For frameIdx As Integer = 0 To framesCount - 1
            ' Insert a section break before each new page, in case of a multi-frame TIFF.
            If frameIdx <> 0 Then
                builder.InsertBreak(BreakType.SectionBreakNewPage)
            End If
    
            ' Select active frame.
            image__1.SelectActiveFrame(dimension, frameIdx)
    
            ' We want the size of the page to be the same as the size of the image.
            ' Convert pixels to points to size the page to the actual image size.
            Dim ps As PageSetup = builder.PageSetup
            ps.PageWidth = ConvertUtil.PixelToPoint(image__1.Width, image__1.HorizontalResolution)
            ps.PageHeight = ConvertUtil.PixelToPoint(image__1.Height, image__1.VerticalResolution)
    
            ' Insert the image into the document and position it at the top left corner of the page.
            builder.InsertImage(image__1, RelativeHorizontalPosition.Page, 0, RelativeVerticalPosition.Page, 0, ps.PageWidth, _
                ps.PageHeight, WrapType.None)
        Next
    End Using
    
    ' Save the document to PDF.
    doc.Save(outputFileName)
    
    

    public by sherazam  3064  0  5  0

    How to Add Text with Transparent Color in PDF File using .NET

    // Enter here the actual content of the snippet.      
    //The following code snippet shows how to add text with transparent color.
    
    //C# Code Sample
    
    // create Document instance
    Document doc = new Document();
    // create page to pages collection of PDF file
    Aspose.Pdf.Page page = doc.Pages.Add();
    
    // create Graph object 
    Aspose.Pdf.Drawing.Graph canvas = new Aspose.Pdf.Drawing.Graph(100, 400);
    // create rectangle instance with certain dimensions
    Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 400, 400);
    // create color object from Alpha color channel
    rect.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(12957183)));
    // add rectanlge to shapes collection of Graph object
    canvas.Shapes.Add(rect);
    // add graph object to paragraphs collection of page object
    page.Paragraphs.Add(canvas);
    // set value to not change position for graph object
    canvas.IsChangePosition = false;
    
    // create TextFragment instance with sample value
    TextFragment text = new TextFragment("transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text ");
    // create color object from Alpha channel
    Aspose.Pdf.Color color = Aspose.Pdf.Color.FromArgb(30, 0, 255, 0);
    // set color information for text instance
    text.TextState.ForegroundColor = color;
    // add text to paragraphs collection of page instance
    page.Paragraphs.Add(text);
    // save PDF file
    doc.Save("c:/Transparent_Text.pdf");
    
    //VB.NET Code Sample
    
    ' create Document instance
    Dim doc As Document = New Document()
    ' create page to pages collection of PDF file
    Dim page As Aspose.Pdf.Page = doc.Pages.Add()
    
    ' create Graph object
    Dim canvas As Aspose.Pdf.Drawing.Graph = New Aspose.Pdf.Drawing.Graph(100, 400)
    ' create rectangle instance with certain dimensions
    Dim rect As Aspose.Pdf.Drawing.Rectangle = New Aspose.Pdf.Drawing.Rectangle(100, 100, 400, 400)
    ' create color object from Alpha color channel
    rect.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(12957183)))
    ' add rectanlge to shapes collection of Graph object
    canvas.Shapes.Add(rect)
    ' add graph object to paragraphs collection of page object
    page.Paragraphs.Add(canvas)
    ' set value to not change position for graph object
    canvas.IsChangePosition = False
    
    ' create TextFragment instance with sample value
    Dim text As Aspose.Pdf.Text.TextFragment = New TextFragment("transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text ")
    ' create color object from Alpha channel
    Dim color As Aspose.Pdf.Color = Aspose.Pdf.Color.FromArgb(30, 0, 255, 0)
    ' set color information for text instance
    Text.TextState.ForegroundColor = color
    ' add text to paragraphs collection of page instance
    page.Paragraphs.Add(Text)
    ' save PDF file
    doc.Save("c:/Transparent_Text.pdf")
          

    public by sherazam  2150  0  5  0

    How to Add Rectangle or Line Object to An Existing PDF File using .NET

    This technical tip shows how .NET developers can add line object to an Existing PDF File inside their .NET applications. Aspose.Pdf for .NET supports the feature to add graph objects (for example graph, line, rectangle etc.) to PDF documents. You also get the leverage to add Line object where you can also specify the dash pattern, color and other f
    // Enter here the actual content of the snippet.   
    //The following code snippet shows how to add a Rectangle object that is filled with color.
    
    //[C# Code]
     
    // Create Document instance
    Document doc = new Document();
    // Add page to pages collection of PDF file
    Page page = doc.Pages.Add();
    // Create Graph instance
    Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(100, 400);             
    // Add graph object to paragraphs collection of page instance
    page.Paragraphs.Add(graph);
    // Create Rectangle instance
    Aspose.Pdf.Drawing.Line line = new Aspose.Pdf.Drawing.Line(new float[]{100, 100, 200, 100});
    // Specify fill color for Graph object
    line.GraphInfo.DashArray = new int[] { 0, 1, 0 };
    line.GraphInfo.DashPhase = 1;
    // Add rectangle object to shapes collection of Graph object
    graph.Shapes.Add(line);
    // Save PDF file
    doc.Save("c:/pdftest/LineAdded.pdf");
    
    //[VB.NET Code]
     
    ' Create Document instance
    Dim doc As Document = New Document()
    ' Add page to pages collection of PDF file
    Dim page As Page = doc.Pages.Add()
    ' Create Graph instance
    Dim graph As Aspose.Pdf.Drawing.Graph = New Aspose.Pdf.Drawing.Graph(100, 400)
    ' Add graph object to paragraphs collection of page instance
    page.Paragraphs.Add(graph)
    ' Create Rectangle instance
    Dim line As Aspose.Pdf.Drawing.Line = New Aspose.Pdf.Drawing.Line(New Single() {100, 100, 200, 100})
    ' Specify fill color for Graph object
    line.GraphInfo.DashArray = New Integer() {0, 1, 0}
    line.GraphInfo.DashPhase = 1
    ' Add rectangle object to shapes collection of Graph object
    graph.Shapes.Add(line)
    ' Save PDF file
    doc.Save("c:/pdftest/LineAdded.pdf")
    
    //DashLengthInBlack and DashLengthInWhite properties for Line object
    
    //[C# Code]
     
     // instantiate Document instance
    Document doc = new Document();
    // add page to pages collection of Document object
    Page page = doc.Pages.Add();
    // create Drawing object with certain dimensions
    Aspose.Pdf.Drawing.Graph canvas = new Aspose.Pdf.Drawing.Graph(100, 400);
    // add drawing object to paragraphs collection of page instance
    page.Paragraphs.Add(canvas);
    // create Line object
    Aspose.Pdf.Drawing.Line line = new Aspose.Pdf.Drawing.Line(new float[] { 100, 100, 200, 100 });
    // set color for Line object
    line.GraphInfo.Color = Aspose.Pdf.Color.Red;
    // specify dash array for line object
    line.GraphInfo.DashArray = new int[] { 0, 1, 0 };
    // set the dash phase for Line instance
    line.GraphInfo.DashPhase = 1;
    // add line to shapes collection of drawing object
    canvas.Shapes.Add(line);
    // save PDF document
    doc.Save("c:/DashLineInBlack.pdf");
    
    //[VB.NET Code]
     
    ' instantiate Document instance
    Dim doc As Document = New Document()
    ' add page to pages collection of Document object
    Dim page As Page = doc.Pages.Add()
    ' create Drawing object with certain dimensions
    Dim canvas As Aspose.Pdf.Drawing.Graph = New Aspose.Pdf.Drawing.Graph(100, 400)
    ' add drawing object to paragraphs collection of page instance
    page.Paragraphs.Add(canvas)
    ' create Line object
    Dim line As Aspose.Pdf.Drawing.Line = New Aspose.Pdf.Drawing.Line(New Single() {100, 100, 200, 100})
    ' set color for Line object
    line.GraphInfo.Color = Aspose.Pdf.Color.Red
    ' specify dash array for line object
    line.GraphInfo.DashArray = New Integer() {0, 1, 0}
    ' set the dash phase for Line instance
    line.GraphInfo.DashPhase = 1
    ' add line to shapes collection of drawing object
    canvas.Shapes.Add(line)
    ' save PDF document
    doc.Save("c:/DashLineInBlack.pdf")
    
    

    public by sherazam  2876  3  5  0

    How to Convert PDF Pages to TIFF Image inside .NET Applications

    This technical tip shows how to convert PDF pages to TIFF image inside .NET Applications. The TiffDevice class allows you to convert PDF pages to TIFF images. This class provides a method named Process which allows you to convert all the pages in a PDF file to a single TIFF image. To convert a particular page in a PDF file to a TIFF image, use an
    // Enter here the actual content of the snippet.            
    //The following code snippet shows how to convert all the PDF pages to a single TIFF image.
    
    //[C# Code Sample]
     
    
    // Open document
    Document pdfDocument = new Document("input.pdf");
    
    // Create Resolution object
    Resolution resolution = 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(resolution, tiffSettings);
    
    // Convert a particular page and save the image to stream
    tiffDevice.Process(pdfDocument, "output.tif");
    
    //[VB.NET Code Sample]
     
    
    'Open document
    Dim pdfDocument As New Document("input.pdf")
    
    'Create Resolution object
    Dim resolution As New Resolution(300)
    
    'Create TiffSettings object
    Dim tiffSettings As New TiffSettings()
    tiffSettings.Compression = CompressionType.None
    tiffSettings.Depth = ColorDepth.Default
    tiffSettings.Shape = ShapeType.Landscape
    tiffSettings.SkipBlankPages = False
    
    'Create TIFF device
    Dim tiffDevice As New TiffDevice(resolution, tiffSettings)
    
    'Convert a particular page and save the image to stream
    tiffDevice.Process(pdfDocument, "output.tif")
    
    
    //Convert One Page to TIFF Image
    
    //[C# Code Sample]
     
    
    // Open document
    Document pdfDocument = new Document("input.pdf");
    
    // Create Resolution object
    Resolution resolution = 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(resolution, tiffSettings);
    
    
    // Convert a particular page and save the image to stream
    tiffDevice.Process(pdfDocument, 1, 1, "output.tif");
    
    
    //[VB.NET Code Sample]
     
    
    'Open document
    Dim pdfDocument As New Document("input.pdf")
    
    'Create Resolution object
    Dim resolution As New Resolution(300)
    
    'Create TiffSettings object
    Dim tiffSettings As New TiffSettings()
    tiffSettings.Compression = CompressionType.None
    tiffSettings.Depth = ColorDepth.Default
    tiffSettings.Shape = ShapeType.Landscape
    tiffSettings.SkipBlankPages = False
    
    'Create TIFF device
    Dim tiffDevice As New TiffDevice(resolution, tiffSettings)
    
    'Convert a particular page and save the image to stream
    tiffDevice.Process(pdfDocument, 1, 1, "output.tif")
    
    //Use Bradley algorithm during conversion
    
    //[C# Code Sample]
     
    
    string outputImageFile = @"c:\resultant.tif";
    string outputBinImageFile = @"c:\37116-bin.tif";
    //open document
    Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(@"c:\input.pdf");
    //create Resolution object
    Resolution resolution = new Resolution(300);
    //create TiffSettings object
    TiffSettings tiffSettings = new TiffSettings();
    tiffSettings.Compression = CompressionType.LZW;
    tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp;
    //create TIFF device
    TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
    //convert a particular page and save the image to stream
    tiffDevice.Process(pdfDocument, outputImageFile);
    
    using (FileStream inStream = new FileStream(outputImageFile, FileMode.Open))
    {
           using (FileStream outStream = new FileStream(outputBinImageFile, FileMode.Create))
           {
                  tiffDevice.BinarizeBradley(inStream, outStream, 0.1);
           }
    }
    
    //[VB.NET Code Sample]
     
    
    Dim outputImageFile As String = "c:\resultant.tif"
    Dim outputBinImageFile As String = "c:\37116-bin.tif"
    'open document
    Dim pdfDocument As Aspose.Pdf.Document = New Aspose.Pdf.Document("c:\input.pdf")
    'create Resolution object
    Dim resolution As Aspose.Pdf.Devices.Resolution = New Aspose.Pdf.Devices.Resolution(300)
    'create TiffSettings object
    Dim tiffSettings As TiffSettings = New TiffSettings()
    tiffSettings.Compression = CompressionType.LZW
    tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp
    'create TIFF device
    Dim tiffDevice As TiffDevice = New TiffDevice(resolution, tiffSettings)
    'convert a particular page and save the image to stream
    tiffDevice.Process(pdfDocument, outputImageFile)
    
    Using inStream As FileStream = New FileStream(outputImageFile, FileMode.Open)
    
        Using outStream As FileStream = New FileStream(outputBinImageFile, FileMode.Create)
            tiffDevice.BinarizeBradley(inStream, outStream, 0.1)
        End Using
    End Using
    
    

    public by johansonkatherine  6337  1  8  5

    Convert PDF from Remote Server to other Format using Aspose.Pdf for Cloud API in PHP

    Aspose.PDF for Cloud API has released PHP SDK which allows PHP developers to convert PDF files uploaded to a remote server to other formats. You can pass URL and format parameters to specify the PDF’s URL and output format and use the PUT method of the convert resource to convert remote PDF files. You can download Aspose Cloud PHP SDK from the link
    use Aspose\Cloud\Common\AsposeApp;
    use Aspose\Cloud\Common\Product;
    use Aspose\Cloud\Pdf\Converter;
    
    AsposeApp::$appSID = '3395ba5c-***';
    AsposeApp::$appKey = 'e8dd1b0cd***';
    
    /* * Creating the object of Pdf Converter Class with a perameter $fileName */
    $Obj = new Converter('path/to/pdf/file.pdf');
    
    // Call convertByUrl method.
    $Obj->convertByUrl('http://url-to-pdf.com/file.pdf','tiff','outputfile.tiff');
    
    

    public by johansonkatherine  3918  0  7  4

    Merge multiple PDFs using PHP SDK from Aspose

    PHP developers can learn how to merge multiple PDF files into a single PDF file using PHP SDK from Aspose. You can use the following given supported third party storage to access Aspose for Cloud service. https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP In order to use PHP SDK, you need to perform following steps: - Set base
    use Aspose\Cloud\Common\AsposeApp;
    use Aspose\Cloud\Common\Utils;
    use Aspose\Cloud\Common\Product;
    use Aspose\Cloud\Storage\Folder;
    use Aspose\Cloud\Pdf\Document;
    
    /**** Section 1 ****/
    
    AsposeApp::$appSID = "77****-****-****-****-80*********";
    AsposeApp::$appKey = "******************";
    $baseProductUri= "http://api.aspose.com/v1.1";
    AsposeApp::$outPutLocation = getcwd() . "/Output/";
    
    /**** End Section 1 ****/
    
    /**** Section 2 ****/
    
    $inputFile1 = getcwd() . "/Input/input1.pdf";
    $inputFile2 = getcwd() . "/Input/input2.pdf";
    $inputFile3 = getcwd() . "/Input/input3.pdf";
    $mergedFileName = "MergedFile.pdf";
    //upload input PDF files
    echo "Uploading main document...<br />";
    $folder = new Folder();
    $folder->UploadFile($inputFile1, "");
    $folder->UploadFile($inputFile2, "");
    $folder->UploadFile($inputFile3, "");
    echo "input files uploaded <br />";
    
    /**** End Section 2 ****/
    
    /**** Section 3 ****/
    echo "Merging PDF files... <br />";
    //create Document object
    $doc = new Document($mergedFileName);
    $result = $doc->mergeDocuments(array('input1.pdf','input2.pdf','input3.pdf'));
    
    /**** End Section 3 ****/
    
    
    • Public Snippets
    • Channels Snippets