<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0303</schemaVersion>

    <documentType>5</documentType>

    <periodOfReport>2009-12-31</periodOfReport>

    <form3HoldingsReported>0</form3HoldingsReported>

    <form4TransactionsReported>0</form4TransactionsReported>

    <issuer>
        <issuerCik>0000102212</issuerCik>
        <issuerName>UNIVEST CORP OF PENNSYLVANIA</issuerName>
        <issuerTradingSymbol>UVSP</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001199487</rptOwnerCik>
            <rptOwnerName>AICHELE WILLIAM S</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>1401 RICKERT ROAD</rptOwnerStreet1>
            <rptOwnerStreet2></rptOwnerStreet2>
            <rptOwnerCity>PERKASIE</rptOwnerCity>
            <rptOwnerState>PA</rptOwnerState>
            <rptOwnerZipCode>18944</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>0</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>Director, Chairman, Pres &amp; CEO</officerTitle>
        </reportingOwnerRelationship>
    </reportingOwner>

    <nonDerivativeTable>
        <nonDerivativeHolding>
            <securityTitle>
                <value>COMMON</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>94904.091</value>
                    <footnoteId id="F1"/>
                    <footnoteId id="F2"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
        <nonDerivativeHolding>
            <securityTitle>
                <value>COMMON</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>9608.71</value>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>Trustee - Deferred Salary Savings Plan</value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <derivativeTable>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>28.2667</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2005-12-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2013-12-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>20249</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>20249</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>24.27</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2007-12-30</value>
            </exerciseDate>
            <expirationDate>
                <value>2015-12-30</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>15000</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>15000</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>21.11</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2009-12-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2017-12-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>27000</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>27000</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>17.53</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2009-12-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2017-12-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>5000</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>5000</value>
                    <footnoteId id="F4"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>22.90</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2010-01-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2018-01-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>2003</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>2003</value>
                    <footnoteId id="F5"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>22.90</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2011-01-31</value>
            </exerciseDate>
            <expirationDate>
                <value>2019-01-31</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>7500</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>7500</value>
                    <footnoteId id="F6"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>STOCK OPTIONS</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>24.40</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2011-02-02</value>
            </exerciseDate>
            <expirationDate>
                <value>2019-02-02</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>COMMON</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>2305</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>2305</value>
                    <footnoteId id="F7"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </derivativeHolding>
    </derivativeTable>

    <footnotes>
        <footnote id="F1">DOES INCLUDE 2,824.0910 SHARES ACQUIRED ON OR AFTER AUGUST 15, 1996 THROUGH THE DIVIDEND REINVESTMENT PLAN AND EMPLOYEE STOCK PURCHASE PLAN.</footnote>
        <footnote id="F2">DOES INCLUDE 13,073 SHARES OF RESTRICTED STOCK.</footnote>
        <footnote id="F3">TRUSTEE'S ALLOCATED PECUNIARY INTEREST IN THE SHARES HELD IN THE DEFERRED SALARY SAVINGS PLAN.</footnote>
        <footnote id="F4">DOES INCLUDE 1,666 SHARES OF RESTRICTED STOCK.</footnote>
        <footnote id="F5">DOES INCLUDE 1,602 SHARES OF RESTRICTED STOCK.</footnote>
        <footnote id="F6">DOES INCLUDE 7,500 SHARES OF RESTRICTED STOCK.</footnote>
        <footnote id="F7">DOES INCLUDE 2,305 SHARES OF RESTRICTED STOCK.</footnote>
    </footnotes>

    <remarks></remarks>

    <ownerSignature>
        <signatureName>Jeffrey M. Schweitzer</signatureName>
        <signatureDate>2010-02-08</signatureDate>
    </ownerSignature>
</ownershipDocument>
